/*******************************************************
* This file is generated automatically by gentypes.lisp.
* DO NOT MAKE CHANGES TO THIS FILE DIRECTLY.
********************************************************/

#ifndef __YJKTYPES_H
#define __YJKTYPES_H

#include <stdint.h>

// These are basic types that can exist in arrays.
#define YJK_BASETYPE_OBJECT 1
#define YJK_BASETYPE_INT8   2
#define YJK_BASETYPE_CHAR   3
#define YJK_BASETYPE_INT16  4
#define YJK_BASETYPE_INT32  5
#define YJK_BASETYPE_INT64  6
#define YJK_BASETYPE_FLOAT  7

#define YJK_BASETYPE_LIMIT  7
#define YJK_IS_BASETYPE(x) (x <= YJK_BASETYPE_LIMIT)


//Represents object type.
//Defined near end of file.
typedef uint8_t yjk_type_t;

typedef struct
{
  uint8_t    flags;
  yjk_type_t type;
  uint32_t   size;
} YJK_OBJECT_HEADER;


#ifndef __64BIT__
typedef struct 
{
  unsigned int tag : 2;
  int value : 30;
} YJK_MASK;
typedef int32_t YJK_FIXNUM;
#else
typedef struct
{
  unsigned int tag : 2;
  int value : 62;
} YJK_MASK;
typedef int64_t YJK_FIXNUM;
#endif

typedef void *YJK_FUNCTION;

struct yjk_floatp;
struct yjk_ratio;
struct yjk_complex;
struct yjk_array;
struct yjk_hash;
struct yjk_bignum;
struct yjk_utf8_string;
typedef union 
{
  YJK_MASK   mask;
  YJK_FIXNUM fixnum;
  YJK_OBJECT_HEADER *head;
  struct yjk_floatp *floatp;
  struct yjk_ratio *ratio;
  struct yjk_complex *complex;
  struct yjk_array *array;
  struct yjk_hash *hash;
  struct yjk_bignum *bignum;
  struct yjk_utf8_string *utf8_string;
} YJK_OBJECT;

struct yjk_floatp {
  YJK_OBJECT_HEADER head;
  double value;
};
typedef struct yjk_floatp YJK_FLOATP;

struct yjk_ratio {
  YJK_OBJECT_HEADER head;
  YJK_OBJECT numerator;
  YJK_OBJECT denominator;
};
typedef struct yjk_ratio YJK_RATIO;

struct yjk_complex {
  YJK_OBJECT_HEADER head;
  YJK_OBJECT rpart;
  YJK_OBJECT ipart;
};
typedef struct yjk_complex YJK_COMPLEX;

struct yjk_array {
  YJK_OBJECT_HEADER head;
  struct {
    int32_t element_type; 
    int32_t size; 
    YJK_OBJECT data[]; 
  } flex;
};
typedef struct yjk_array YJK_ARRAY;

struct yjk_hash {
  YJK_OBJECT_HEADER head;
  int32_t num_elements;
  YJK_FUNCTION * hash_function;
  struct {
    int32_t element_type; 
    int32_t size; 
    YJK_OBJECT data[]; 
  } buckets;
};
typedef struct yjk_hash YJK_HASH;

struct yjk_bignum {
  YJK_OBJECT_HEADER head;
  int32_t data_size;
  int32_t data[];
};
typedef struct yjk_bignum YJK_BIGNUM;

struct yjk_utf8_string {
  YJK_OBJECT_HEADER head;
  int32_t data_size;
  unsigned char data[];
};
typedef struct yjk_utf8_string YJK_UTF8_STRING;

#define YJK_FIXNUM_T        11
#define YJK_FLOATP_T        12
#define YJK_RATIO_T         13
#define YJK_COMPLEX_T       14
#define YJK_ARRAY_T         15
#define YJK_HASH_T          16
#define YJK_BIGNUM_T        17
#define YJK_UTF8_STRING_T   18


yjk_type_t yjk_get_type(YJK_OBJECT);

#endif //__YJKTYPES_H
